﻿<script type="text/javascript">
    $(function () {
        getButton("hzBaseByZheng");
    });

    function ui_hzBaseByZheng_init_list(toolbar) {
        $("#ui_hzBaseByZheng_dg").datagrid({       //初始化datagrid
            url: "ashx/bg_hzBaseByZheng.ashx?action=getall",
            striped: true, rownumbers: true,
            singleSelect: true,
            idField: 'pcode',
            sortName: 'pcode',
            sortOrder: 'asc',
            columns: [[
                
                { field: 'pname', title: '骨灰堂名称', width: 120 },
                { field: 'totalgraves', title: '号码总数', width: 100 },
                { field: 'occupygraves', title: '已存号总数', width: 100 },
                { field: 'emptygraves', title: '空号总数', width: 100 },
                { field: 'singlegraves', title: '单穴总数', width: 100 },
                { field: 'doublegraves', title: '双穴总数', width: 100 },
                { field: 'multigraves', title: '多穴总数', width: 100 },
                { field: 'totaldeads', title: '总容量', width: 100 },
                { field: 'storedeads', title: '已存骨灰数', width: 100 },
                { field: 'emptydeads', title: '空余容量', width: 100 }

            ]],
            rowStyler: function (index, row) {
                if (!row.pcode) {
                    return 'background-color:#6293BB;color:#fff;font-weight:bold;';
                }
            },
            footer: "#ui_hzBaseByZheng_dg_ft"
            //toolbar: toolbar.length == 0 ? null : toolbar
            //toolbar: [{
            //    text: '导出',
            //    iconCls: 'icon-bug_go',
            //    handler: function () { ui_hzBaseByZheng_export(); }
            //}, {
            //    text: '删除',
            //    iconCls: 'icon-bug_delete',
            //    handler: function () { ui_hzBaseByZheng_delete(); }
            //}, {
            //    text: '回复',
            //    iconCls: 'icon-bug_edit',
            //    handler: function () { ui_hzBaseByZheng_edit(); }
            //}]           
        });        
        var url = "ashx/bg_hzBaseByZheng.ashx?action=export&areacode=&type=";
        $('#ui_hzBaseByZheng_btn_export').attr("url", url);
    }
    function ui_hzBaseByZheng_search() {
        var type = $('#ui_hzBaseByZheng_type').combobox('getValue');
        var areacode = $('#ui_hzBaseByZheng_areacode').combotree('getValue');
        var aname = $('#ui_hzBaseByZheng_areacode').combotree('getText');
        if (aname.length > 0) {
            $("#ui_hzBaseByZheng_cityname").text("【" + aname + "】");
        } else {
            $("#ui_hzBaseByZheng_cityname").text("全市");
        }
        var url = "ashx/bg_hzBaseByZheng.ashx?action=export&areacode=" + areacode+"&type="+type;
        $('#ui_hzBaseByZheng_btn_export').attr("url", url );
        $('#ui_hzBaseByZheng_dg').datagrid("load", { type:type, areacode: areacode });
    }

    function ui_hzBaseByZheng_export() {
        var url = $('#ui_hzBaseByZheng_btn_export').attr("url");
        if (!url) {
            $.show_warning("提示", "请先查询结果，然后再导出");
            return;            
        }
        var t = new Date().getTime();
        url = url + "&t=" + t;
        $('#ui_hzBaseByZheng_export_excel').attr('src', url);
    }
    function ui_hzBaseByZheng_export2() {
        var url = $('#ui_hzBaseByZheng_btn_export2').attr("url");
        if (url) {
            var t = new Date().getTime();
            url = url + "&t=" + t;
            $('#ui_hzBaseByZheng_export_excel').attr('src', url);
        }
    }
    function ui_hzBaseByZheng_detail() {        
        var rows = $("#ui_hzBaseByZheng_dg").datagrid("getChecked");
        if (rows.length != 1) {
            $.show_warning("提示", "请先选择要一行数据");
            return;
        }        
        var row = rows[0];
        var $ui_hzBaseByZheng_layout = $("#ui_hzBaseByZheng_layout");
        var westHzBaseByZheng = $ui_hzBaseByZheng_layout.layout("panel", "east");

        if (westHzBaseByZheng.panel("options").collapsed) {   //判断是否展开
            $ui_hzBaseByZheng_layout.layout("expand", "east");
        }

        var url = "ashx/bg_hzBaseSectionBy.ashx?action=export&paradiseid=" + row.pcode;
        $('#ui_hzBaseByZheng_btn_export2').attr("url", url);
        
        westHzBaseByZheng.panel("setTitle", "【"+row.pname + "】内部基本情况统计");
        if ($("#ui_hzBaseByZheng_dg2").data("datagrid")) {
            $("#ui_hzBaseByZheng_dg2").datagrid({       //请求数据
                url: "ashx/bg_hzBaseSectionBy.ashx?action=getall&paradiseid=" + row.pcode
            });
        }
        else {
            $("#ui_hzBaseByZheng_dg2").datagrid({       //初始化datagrid
                url: "ashx/bg_hzBaseSectionBy.ashx?action=getall&paradiseid=" + row.pcode,
                striped: true, rownumbers: true,
                singleSelect: true,
                idField: 'pcode',
                sortName: 'pcode',
                sortOrder: 'asc',
                columns: [[

                    { field: 'pname', title: '区名', width: 120 },
                    { field: 'totalgraves', title: '号码总数', width: 80 },
                    { field: 'occupygraves', title: '已存号数', width: 80 },
                    { field: 'emptygraves', title: '空号总数', width: 80 },
                    { field: 'singlegraves', title: '单穴总数', width:80 },
                    { field: 'doublegraves', title: '双穴总数', width: 80 },
                    { field: 'multigraves', title: '多穴总数', width: 80 },
                    { field: 'totaldeads', title: '总容量', width: 80 },
                    { field: 'storedeads', title: '已存骨灰数', width: 80 },
                    { field: 'emptydeads', title: '空余容量', width: 80 }

                ]],
                rowStyler: function (index, row) {
                    if (!row.pcode) {
                        return 'background-color:#6293BB;color:#fff;font-weight:bold;';
                    }
                },
                footer: "#ui_hzBaseByZheng_dg2_ft"
                //,
                //toolbar: toolbar.length == 0 ? null : toolbar
                //toolbar: [{
                //    text: '导出',
                //    iconCls: 'icon-bug_go',
                //    handler: function () { ui_hzBaseSectionBy_export(); }
                //}, {
                //    text: '删除',
                //    iconCls: 'icon-bug_delete',
                //    handler: function () { ui_hzBaseSectionBy_delete(); }
                //}, {
                //    text: '回复',
                //    iconCls: 'icon-bug_edit',
                //    handler: function () { ui_hzBaseSectionBy_edit(); }
                //}]           
            });
        }
        
    }
    
</script>
<div id="ui_hzBaseByZheng_layout" class="easyui-layout" data-options="fit:true,border:false"> 
    <div style="display:none"><iframe id="ui_hzBaseByZheng_export_excel" style="display:none"></iframe></div>  
    <div id="ui_hzBaseByZheng_layout_center" data-options="region:'center',border:false">        
        <div  id="ui_hzBaseByZheng_layout_toolbar" class="datagrid-toolbar" style="padding: 2px 5px;">
            <select class="easyui-combobox" name="ui_hzBaseByZheng_type" id="ui_hzBaseByZheng_type" data-options="panelHeight:120,editable:false">
                <option value="all">全部</option>
                <option value="骨灰堂">骨灰堂</option>
                <option value="埋葬地">埋葬地</option>     
                <option value="公墓">公墓</option>
                <option value="塔园">塔园</option>                                        
                <option value="其他">其他</option>
            </select>
            <input class="easyui-combotree" id="ui_hzBaseByZheng_areacode" name="ui_hzBaseByZheng_areacode"
                                data-options="url: 'ashx/bg_area.ashx?action=getzheng', lines:true,required:true" />
            <img style="cursor: pointer; vertical-align: middle;" onclick="$('#ui_hzBaseByZheng_areacode').combotree('clear');"
                        alt="清空" title="清空" src="themes/icons/edit-clear.png" />
            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="ui_hzBaseByZheng_search()">查询</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-export" onclick="ui_hzBaseByZheng_export()" id="ui_hzBaseByZheng_btn_export" >导出</a>  
            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-store" onclick="ui_hzBaseByZheng_detail()">内部基本情况统计</a>
        </div>
       
        <div id="ui_hzBaseByZheng_layout_header" class="datagrid-header" style="text-align: center; font-weight: 600"><span id="ui_hzBaseByZheng_cityname">全市</span>骨灰堂基本情况汇总表</div>
        <table id="ui_hzBaseByZheng_dg" data-options="fit:true,border:false">
        </table>
        <div id="ui_hzBaseByZheng_dg_ft" style="height:50px"></div>
    </div>
    <div data-options="region:'east',split:true,border:true,collapsed:true" title="内部基本情况统计">
        <div  class="datagrid-toolbar" style="padding: 2px 5px;">            
            <a href="javascript:void(0);"class="easyui-linkbutton" onclick="ui_hzBaseByZheng_export2()" id="ui_hzBaseByZheng_btn_export2" iconcls="icon-export" >导出</a>              
        </div>
        <table id="ui_hzBaseByZheng_dg2" data-options="fit:true,border:false">
        </table>
        <div id="ui_hzBaseByZheng_dg2_ft" style="height:50px"></div>
    </div>
</div>
